package com.mycms.util;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class EncryptUtil {
	
	/**
	 * SHA 암호화
	 * 
	 * @param password
	 * @return
	 * @throws NoSuchAlgorithmException
	 * @throws UnsupportedEncodingException
	 */
	public static String encryptSha256(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
		MessageDigest digest = MessageDigest.getInstance("SHA-256");
		digest.reset();
		String strAddedsalt = password + "mycms-sha256";
		byte[] hash = digest.digest(strAddedsalt.getBytes("UTF-8"));
		BigInteger bigInt = new BigInteger(1, hash);
		return bigInt.toString(16);		
	}

}
